local ty_1v2_jm = fk.CreateSkill {
    name = "ty_1v2_jm&",
}

Fk:loadTranslationTable {
    ["ty_1v2_jm&"] = "葭萌",
    [":ty_1v2_jm&"] = "出牌阶段限一次，你可以交给一名联军一张牌，其有20％概率令一名联军死亡，否则你视为对其使用一张【杀】。",

    ["@ty_1v2_jm"] = "葭萌",
}
--将输入的整数设置为百分比
function Zsbfb(number)
    return tostring(number) .. "%"
end

ty_1v2_jm:addEffect("active", {
    anim_type = "offensive",
    prompt = "你可以让一名敌人有概率叛变！",
    card_num = 1,
    target_num = 1,
    card_filter = function(self, player, to_select, selected)
        return #selected == 0
    end,
    target_filter = function(self, player, to_select, selected)
        return #selected == 0 and to_select ~= player
    end,
    can_use = function(self, player)
        return player:usedSkillTimes(ty_1v2_jm.name, Player.HistoryPhase) == 0 and not player:isNude()
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target = effect.tos[1]
        if player:getMark("addjm") == 0 then
            room:setPlayerMark(player, "addjm", 1)
            room:setPlayerMark(player, "@ty_1v2_jm", Zsbfb(20))
        end
        if player.dead or not table.contains(player:getCardIds("he"), effect.cards[1]) then return end
        local card = Fk:getCardById(effect.cards[1])
        room:obtainCard(target, card, true, fk.ReasonGive, player, ty_1v2_jm.name)
        local random = tonumber(string.sub(player:getMark("@ty_1v2_jm"), 1, -2)) / 100
        if math.random() < random then
            room:killPlayer({ who = target })
            -- target.role = "loyalist"
            -- room:broadcastProperty(target, "role")
            -- local n = 0
            -- for _, id in ipairs(room:getOtherPlayers(player)) do
            --     if id.role == "loyalist" or id.role == "lord" then
            --         n = n + 1
            --     end
            -- end
            -- if n == #room.alive_players then
            --     room:gameOver("lord+loyalist")
            -- end
        else
            -- local num = tonumber(string.sub(player:getMark("@ty_1v2_jm"), 1, -2))
            -- room:setPlayerMark(player, "@ty_1v2_jm", Zsbfb(num + 10))
            room:useVirtualCard('slash', nil, player, target, ty_1v2_jm.name, true)
        end
    end,
})

return ty_1v2_jm
